import java.util.ArrayList;

public class CreateSampleDB {
	public CreateSampleDB() {

	}

	public boolean createDB(String name, String r, String rs, String fd) {
		InputProcessing in = new InputProcessing();
		ArrayList<String> R = in.getAttributes(r);
		ArrayList<String> R_s = in.setNullFreeSubSchema(rs);
		ArrayList<FuncDep> FD = in.setFD(fd);

		return sampling(R, R_s, FD, name);
	}

	private static boolean sampling(ArrayList<String> r, ArrayList<String> r_s,
			ArrayList<FuncDep> fd, String table) {
		SetManipulator setManipulator = new SetManipulator();
		ArrayList<ArrayList<String>> maxSets = setManipulator.computeMaxSets2(
				r, r_s, fd);

		System.out.println(maxSets.size());
		for (int i = 0; i < maxSets.size(); i++) {
			for (int j = 0; j < maxSets.get(i).size(); j++) {
				System.out.print(maxSets.get(i).get(j) + " ");
			}
			System.out.println();
		}
		// ArrayList<ArrayList<String>> maxSets = setManipulator.computeMaxSets(
		// r, r_s, fd);

		Armstrong armstrong = new Armstrong();
		return armstrong.compute(r, r_s, maxSets, table);
	}
}
